// When color definition differs for dark and light variant,
// it gets @if ed depending on $variant

@import 'color-palette';

@function gtkalpha($c, $a) {
  @return unquote("alpha(#{$c}, #{$a})");
}

@function fade($c) {
  @return mix($c, $grey_900, 50%);
}

// Theme dark colors
$theme_grey_50: if($color == 'default', $green_grey_50, $blue_grey_50);
$theme_grey_100: if($color == 'default', $green_grey_100, $blue_grey_100);
$theme_grey_200: if($color == 'default', $green_grey_200, $blue_grey_200);
$theme_grey_300: if($color == 'default', $green_grey_300, $blue_grey_300);
$theme_grey_400: if($color == 'default', $green_grey_400, $blue_grey_400);
$theme_grey_500: if($color == 'default', $green_grey_500, $blue_grey_500);
$theme_grey_600: if($color == 'default', $green_grey_600, $blue_grey_600);
$theme_grey_700: if($color == 'default', $green_grey_700, $blue_grey_700);
$theme_grey_800: if($color == 'default', $green_grey_800, $blue_grey_800);
$theme_grey_900: if($color == 'default', $green_grey_900, $blue_grey_900);

// Foreground colors
$dark_fg_color:   rgba($black, 0.87);
$light_fg_color:  $white;

$fg_color:                    if($variant == 'light', rgba($black, 0.75), $white);
$button_fg_color:             if($variant == 'light', rgba($black, 0.62), rgba($white, 0.8)); // extra fg color for raised buttons
$secondary_fg_color:          if($variant == 'light', rgba($black, 0.54), rgba($white, 0.7));
$hint_fg_color:               if($variant == 'light', rgba($black, 0.38), rgba($white, 0.5));
$disabled_fg_color:           if($variant == 'light', rgba($black, 0.38), rgba($white, 0.5));
$disabled_secondary_fg_color: if($variant == 'light', rgba($black, 0.26), rgba($white, 0.3));
$track_color:                 if($variant == 'light', rgba($black, 0.26), rgba($white, 0.3));
$divider_color:               if($variant == 'light', rgba($black, 0.12), rgba($white, 0.12));

$titlebar_fg_color:                    if($titlebar == 'light', rgba($black, 0.75), $white);
$titlebar_secondary_fg_color:          if($titlebar == 'light', rgba($black, 0.54), rgba($white, 0.7));
$titlebar_hint_fg_color:               if($titlebar == 'light', rgba($black, 0.38), rgba($white, 0.5));
$titlebar_disabled_fg_color:           if($titlebar == 'light', rgba($black, 0.38), rgba($white, 0.5));
$titlebar_disabled_secondary_fg_color: if($titlebar == 'light', rgba($black, 0.26), rgba($white, 0.3));
$titlebar_track_color:                 if($titlebar == 'light', rgba($black, 0.26), rgba($white, 0.3));
$titlebar_divider_color:               if($titlebar == 'light', rgba($black, 0.12), rgba($white, 0.12));

$inverse_fg_color:                    $white;
$inverse_secondary_fg_color:          rgba($white, 0.7);
$inverse_hint_fg_color:               rgba($white, 0.5);
$inverse_disabled_fg_color:           rgba($white, 0.5);
$inverse_disabled_secondary_fg_color: rgba($white, 0.3);
$inverse_track_color:                 rgba($white, 0.3);
$inverse_divider_color:               rgba($white, 0.12);

$panel_fg_color:                      if($titlebar == 'light', rgba($black, 0.75), rgba($white, 0.8));
$panel_secondary_fg_color:            if($titlebar == 'light', rgba($black, 0.62), rgba($white, 0.68));
$panel_hint_fg_color:                 if($titlebar == 'light', rgba($black, 0.38), rgba($white, 0.5));
$panel_disabled_fg_color:             if($titlebar == 'light', rgba($black, 0.38), rgba($white, 0.5));
$panel_disabled_secondary_fg_color:   if($titlebar == 'light', rgba($black, 0.26), rgba($white, 0.3));
$panel_track_color:                   if($titlebar == 'light', rgba($black, 0.26), rgba($white, 0.3));
$panel_divider_color:                 if($titlebar == 'light', rgba($black, 0.12), rgba($white, 0.12));

// Background colors
$bg_color:               if($variant == 'light', $grey_100, fade($theme_grey_700));
$base_color:             if($variant == 'light', darken($white, 1%), fade($theme_grey_600));
$alt_base_color:         if($variant == 'light', $grey_50, mix($base_color, $bg_color, 50%));
$lighter_bg_color:       if($variant == 'light', $grey_100, fade($theme_grey_500));
$alt_lighter_bg_color:   if($variant == 'light', $grey_200, fade($theme_grey_800)); // for gnome-shell sub menu
$darker_bg_color:        if($variant == 'light', $grey_200, fade($theme_grey_900));
$keyboard_bg_color:      if($variant == 'light', $grey_50, fade($theme_grey_600)); // for gnome-shell keyboard
$alt_keyboard_bg_color:  if($variant == 'light', $grey_300, fade($theme_grey_900)); // for gnome-shell keyboard

$titlebar_bg_color:      if($titlebar == 'dark', if($variant == 'light', $theme_grey_700, $theme_grey_900), $white);
$alt_titlebar_bg_color:  if($titlebar == 'dark', $theme_grey_600, $grey_300);

$panel_bg_color:         rgba(if($titlebar == 'dark', $theme_grey_900, $white), 0.85);
$alt_panel_bg_color:     rgba(if($titlebar == 'dark', $theme_grey_800, $grey_50), 0.85);
$inverse_panel_bg_color: rgba($titlebar_fg_color, 0.1);
$solid_panel_bg_color:   if($titlebar == 'dark', $theme_grey_900, $white);
$opaque_panel_bg_color:  $solid_panel_bg_color; // for Unity panel which cannot use translucent colors

$gdm_bg_color:  if($variant == 'light', $theme_grey_800, $theme_grey_900);
$menu_bg_color: if($variant == 'light', $white, $bg_color);

$fill_color:      gtkalpha(currentColor, $lower_opacity);
$semi_fill_color: gtkalpha(currentColor, $lower_opacity / 2);
$row_fill_color:  gtkalpha(currentColor, 0.05);

// Misc colors
$primary_color: #00CE99;
$alt_primary_color: #00CF88;

@if $color == 'blue' {
  $primary_color: #3e81ff;
  $alt_primary_color: #4c89fd;
}

@if $color == 'indigo' {
  $primary_color: #7349ff;
  $alt_primary_color: #8600e8;
}

$progress_color: $primary_color;
$accent_color: #FFAC00;
$disabled_accent_color: rgba($accent_color, 0.5);

$link_color:         $primary_color;
$visited_link_color: $purple_A200;

$warning_color: $orange_A700;
$error_color:   $deep_orange_A700;
$success_color: $green_A700;

$suggested_color:   $accent_color;
$destructive_color: $red_A200;

$info_bg_color:     $green_400;
$question_bg_color: $blue_400;
$warning_bg_color:  $orange_400;
$error_bg_color:    $red_400;

$border_color:             if($variant == 'light', rgba($black, 0.08), rgba($white, 0.08));
$solid_border_color:       if($variant =='light', darken($bg_color, 10%), lighten($bg_color, 8%));
$alt_border_color:         if($variant =='light', darken($bg_color, 15%), darken($bg_color, 5%)); // for non-native GTK+ apps (e.g. Firefox and Chrome)
$highlight_color:          if($variant == 'light', rgba($white, 0.4),  rgba($white, 0.1));
$titlebar_highlight_color: if($titlebar == 'dark', rgba($white, 0.1),  rgba($white, 0.4));
$alt_highlight_color:      rgba($white, 0.2); // for selection-mode headerbar which colored with $primary_color
$indicator_color:          if($titlebar == 'dark', $primary_color, $primary_color);

// for Electron/Atom menu which cannot use translucent colors
$opaque_fg_color:           if($variant == 'light', $grey_900, $white);
$opaque_secondary_fg_color: if($variant == 'light', $grey_600, mix($white, $base_color, percentage(0.7)));
$opaque_disabled_fg_color:  if($variant == 'light', $grey_500, mix($white, $base_color, percentage(0.5)));
$opaque_divider_color:      if($variant == 'light', $grey_300, mix($white, $base_color, percentage(0.12)));

// FIXME: gtk's @placeholder_text_color API really should use $secondary_fg_color,
// but it doesn't work with translucent colors. So we use opaque colors instead.
$placeholder_text_color: if($variant == 'light',
                            mix($black, $base_color, percentage(0.54)),
                            mix($white, $base_color, percentage(0.7)));
